package com.learn.plugins.gen;

import com.hxs.learn.plugins.plugins.gen.AutoGen;
import org.beetl.sql.core.*;
import org.beetl.sql.core.db.AbstractDBStyle;
import org.beetl.sql.core.db.MySqlStyle;
import org.beetl.sql.ext.DebugInterceptor;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

public class GenBqlTools {


    public static void main(String[] args) throws IOException {

        Properties pro = new Properties();
        pro.load(GenBqlTools.class.getResourceAsStream("/jdbc.properties"));
        ConnectionSource source = ConnectionSourceHelper.getSimple(
                (String) pro.get("datasource.driver"),
                (String) pro.get("datasource.url"),
                (String) pro.get("datasource.username"),
                (String) pro.get("datasource.password"));
        String moduleName = "api";
        // 采用mysql习俗
        AbstractDBStyle style = new MySqlStyle();
        // sql语句放在classpagth的/sql 目录下
        SQLLoader loader = new ClasspathLoader("/mappers/" + moduleName);
        NameConversion nc = new UnderlinedNameConversion();
        SQLManager sqlManager = new SQLManager(style, loader, source, nc, new Interceptor[]{new DebugInterceptor()});

        String basepkg = "com.learn.webapi";
        List<String> tables = Arrays.asList(
        );
        AutoGen.go(sqlManager, "learn-project", basepkg, moduleName, tables);
    }


}
